const mysql = require('mysql');

//连接
var db = mysql.createConnection({
    host:'localhost',
    user:'root',
    password:'root',
    database:'nodejs',
    port:'3306'
});


//查询
db.query('select * from user',function(err,data){
    if(err)
        console.log('查询失败');
    else
        console.log(JSON.stringify(data));
});
